#include "CRSF.h"

void setup()
{
  INIT_CRSF();

}

void loop()
{
  uint8_t serialRam = Serial.available();
  for (uint8_t i = 0; i < serialRam; i ++)
  {
    CRSF_DECODE(Serial.read());//解算函数
  }
  if (CRSF_UPDATED())
  {//如果检测到一次IBUS更新
    /*Serial.print(CRSF_VAL(0));
    Serial.print(",");
    Serial.print(CRSF_VAL(1));
    Serial.print(",");
    Serial.print(CRSF_VAL(2));
    Serial.print(",");
    Serial.print(CRSF_VAL(3));
    Serial.print(",");
    Serial.print(CRSF_VAL(4));
    Serial.print(",");
    Serial.print(CRSF_VAL(5));
    Serial.print(",");
    Serial.print(CRSF_VAL(6));
    Serial.print(",");
    Serial.println(CRSF_VAL(7));*/
    
  }
  static unsigned long t;
  if (millis() - t >= 100)
  {
    t = millis();
    CRSF_BATT_TELE(100, 100, 4000, 255);
  }
}
